//
//  ChapterCell.m
//  VNBooks
//
//  Created by hainguyen on 12/15/11.
//  Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//

#import "ChapterCell.h"

@implementation ChapterCell
@synthesize backgroundImage;
@synthesize chapterNameLabel;
@synthesize excerptLabel;
@synthesize arrowButton;
@synthesize chapterThumnail;
@synthesize cellIndex;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated]; 
    if (selected == YES) {
        if (cellIndex == first) {
            self.backgroundImage.image = [UIImage imageNamed:@"chapter_selected_top_cell.png"];
        }else if (cellIndex == middle ) {
            self.backgroundImage.image = [UIImage imageNamed:@"chapter_selected_middle_cell.png"];
        }else{
            self.backgroundImage.image = [UIImage imageNamed:@"chapter_selected_bottom_cell.png"];
        }
    }
    else {
        if (cellIndex == first) {
            self.backgroundImage.image = [UIImage imageNamed:@"chapter_unselected_top_cell.png"];
        }else if (cellIndex == middle ) {
            self.backgroundImage.image = [UIImage imageNamed:@"chapter_unselected_middle_cell.png"];
        }else{
            self.backgroundImage.image = [UIImage imageNamed:@"chapter_unselected_bottom_cell.png"];
        }
    }
}

- (void)dealloc{
    [backgroundImage release];
    [chapterThumnail release];
    [excerptLabel release];
    [arrowButton release];
    [chapterNameLabel release];
    [super dealloc];
}

@end
